package com.zcr.controller;

import com.zcr.pojo.Manager;
import com.zcr.pojo.Permission;
import com.zcr.pojo.Role;
import com.zcr.service.PermissionService;
import com.zcr.service.RoleService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @version 1.0
 * @author： 张诚
 * @date： 2021-03-04 10:16
 */
@Controller
public class IndexController {

    @Resource
    private RoleService roleService;

    @Resource
    private PermissionService permissionService;

    @GetMapping("/index")
    public String index(HttpSession httpSession){
        Manager manager= (Manager) httpSession.getAttribute("LoginUser");
        Role role=roleService.roleByperid(manager.getRoleid());
        System.out.println(role.getPermissionid());
        List<Permission> name = permissionService.getbynameaa(manager.getRoleid().toString());
        httpSession.setAttribute("name",name);
//        System.out.println(name);
        return "index";
    }

}
